<?php
//error_reporting(E_ALL^E_NOTICE^E_WARNING);
// error_reporting( E_ALL );
// error_reporting(7);
error_reporting(0);
function object_array($array) {  
    if(is_object($array)) {  
        $array = (array)$array;  
     } if(is_array($array)) {  
         foreach($array as $key=>$value) {  
             $array[$key] = object_array($value);  
             }  
     }  
     return $array;  
}

require 'config/config.inc.php';
session_start();
$appkey = "23316827";
$secretkey = "5e3b362d3ee55701d60db67681a824be";
function OSAdminAutoLoad($classname){
	
	$filename = str_replace('_', '/', $classname) . '.class.php';
    // class类
    $filepath = ADMIN_BASE_CLASS . $filename;
    if (file_exists($filepath)) {
        return include $filepath;
    }else{
		//仅对Class仅支持一级子目录
		//如果子目录中class文件与CLASS根下文件同名，则子目录里的class文件将被忽略

		$handle=opendir(ADMIN_BASE_CLASS);
		
		while (false !== ($file = readdir($handle))) {
			if (is_dir(ADMIN_BASE_CLASS. "/" . $file)) {
				$filepath=ADMIN_BASE_CLASS."/".$file."/".$filename;
				if (file_exists($filepath)) {
					return include $filepath;
				}
			}
		}
	}
    //lib库文件
    $filepath = ADMIN_BASE_LIB . $filename;
    if (file_exists($filepath)) {
        return include $filepath;
    }

    throw new Exception( $filepath . ' NOT FOUND!');
}
spl_autoload_register('OSAdminAutoLoad');

if(!isset($_SESSION['osa_timezone'])){
		$timezone = System::get('timezone');
		$_SESSION['osa_timezone']=$timezone;
}

date_default_timezone_set($_SESSION['osa_timezone']);

/*
不需要登录就可以访问的链接，也可以是某个目录，不含子目录
如"/nologin/","/nologin/aaa/"
*/

$no_need_login_page=array("/block.php","/panel/login.php","/panel/logout.php",);


Template::assign ( 'osa_templates', $OSA_TEMPLATES);

$sidebarStatus=$_COOKIE['sidebarStatus']==null?"yes":$_COOKIE['sidebarStatus'];
Template::assign ( 'sidebarStatus', $sidebarStatus);

?>

